<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="style.css" />
    <script src="../lib/vue2.js"></script>
  </head>
  <body>
    <div id="box">
      <section>
        <ul>
          <li
            v-for="(item,index) in cardList"
            @click="handleClick(index)"
            :class="current === index?'active':''"
          >
            {{item}}
          </li>
        </ul>
      </section>
    </div>

    <script>
      let boxItem = new Vue({
        el: "#box",
        data: {
          cardList: ["首页", "商城", "我的"],
          current: 0,
        },
        methods: {
          handleClick(index) {
            this.current = index;
          },
        },
      });
    </script>
  </body>
</html>
